package com.xiaoxin.nmzp.validator;

import com.ruoyi.common.nmzp.WorkEx;
import com.xiaoxin.nmzp.interfaces.ValidIfHasExperience;
import com.xiaoxin.nmzp.server.entity.req.ResumeReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.validation.*;
import java.lang.reflect.Field;
import java.util.Set;

//@Component
public class ExperienceValidator implements ConstraintValidator<ValidIfHasExperience, ResumeReq> {
    @Autowired
    private Validator validator;
    @Override
    public boolean isValid(ResumeReq resumeReq, ConstraintValidatorContext context) {
        if (!resumeReq.getIsWorkExperience()) {
            try {
                Field field = resumeReq.getClass().getField("workEx");
                if (field.isAnnotationPresent(Valid.class)) {
                    Valid annotation = field.getAnnotation(Valid.class);
//                    field.
//                    File.removeAnnotation(annotation);
                }
            } catch (NoSuchFieldException e) {
                throw new RuntimeException(e);
            }
        }

        return true;
    }
}
